#include "index.h"
#include "ui_index.h"
#include "uerlogin.h"
#include "borrowcard.h"
#include "database.h"
#include "AdminLogin.h"
#include "form.h"


index::index(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::index)
{
    ui->setupUi(this);
}

index::~index()
{
    delete ui;
}




void index::on_query_clicked()
{
    Form *f=new Form();
    f->show();
}


void index::on_cardhandle_clicked()
{
    borrowcard *b =new borrowcard();
    b->show();
}


void index::on_login_clicked()
{
    QString password=ui->pwd->text();
    QString username=ui->user_name->text();
    if(ui->check->isChecked()){
        if(username=="root"&&password=="123456"){
            QMessageBox::information(this, "提示","管理员成功登录");
            Widget *w=new Widget();
            w->show();
        }else{
            QMessageBox::warning(this, "错误提示","用户名或密码错误");
        }

    }else{
        DataBase da;
        int flag =da.loginCheck(username,password);
        if(flag){
            QMessageBox::information(this, "提示","用户成功登录");
            uerlogin *u=new uerlogin(username);
            u->show();
        }else{
            QMessageBox::warning(this, "错误提示","用户名或密码错误");
        }
    }
}

